package mybag1;

import java.net.InetAddress;
import java.net.UnknownHostException;


/*获取https://www.baidu.com的所有的IP地址
 使用InetAddress类的getAllByName(String host) 对某个有多个IP地址的主机可用于得到一个IP地址数组*/


public class Two {
    public static void main(String[] args) {
        String urlName="www.baidu.com";
        try {
            InetAddress[] hosts = InetAddress.getAllByName(urlName);
            for (InetAddress host : hosts) {
                System.out.println(host.getHostAddress());
            }
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
    }
}

